var mongoose = require('mongoose');

mongoose.connect('mongodb://localhost/test');

var schema = mongoose.Schema;

var commentSchema = new schema({
    id:{
        type:Number,
        required:true
    },
    user_name:{
        type:String,
        required:true
    },
    add_time:{
        type:String,
        required:true
    },
    content:{
        type:String,
        required:true
    },
    pageIndex:{
        type:Number,
        required:true
    }
});
var comment = mongoose.model('comment',commentSchema);
/*var admin = new comment({
    id:1,
    user_name: "ywj",
    add_time:'2018-03-11',
    content: 'hhhh',
    pageIndex: 1
 });
var admin1 = new comment({
    id:1,
    user_name: "ywj",
    add_time:'2018-03-10',
    content: 'hhhh',
    pageIndex: 1
});
var admin2 = new comment({
    id:1,
    user_name: "ywj",
    add_time:'2018-03-19',
    content: 'hhhh',
    pageIndex: 1
});
var admin3 = new comment({
    id:1,
    user_name: "ywj",
    add_time:'2018-03-19',
    content: 'hhhh',
    pageIndex: 2
})

admin.save(function (err, ret) {
  if (err) {
    console.log('保存失败')
  } else {
    console.log('保存成功')
    console.log(ret)
  }
});
admin1.save(function (err, ret) {
    if (err) {
        console.log('保存失败')
    } else {
        console.log('保存成功')
        console.log(ret)
    }
});
admin2.save(function (err, ret) {
    if (err) {
        console.log('保存失败')
    } else {
        console.log('保存成功')
        console.log(ret)
    }
});
admin3.save(function (err, ret) {
    if (err) {
        console.log('保存失败')
    } else {
        console.log('保存成功')
        console.log(ret)
    }
});*/

module.exports = comment;

